package com.songlanyun.modules.disabilityauth.controller.api;

import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.disabilityauth.entity.DisabilityAuthEntity;
import com.songlanyun.modules.disabilityauth.model.DisabilityAuthEntityDTO;
import com.songlanyun.modules.disabilityauth.service.DisabilityAuthService;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 残疾认证
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2022-07-19 14:47:49
 */
@RestController
@RequestMapping("api/disabilityauth")
public class DisabilityApiAuthController extends AbstractApiController {
    @Autowired
    private DisabilityAuthService disabilityAuthService;



    /**
     * 信息
     */
    @RequestMapping("/my")
    //@RequiresPermissions("disabilityauth:disabilityauth:info")
    public R info(){
		DisabilityAuthEntity disabilityAuth = disabilityAuthService.loadByUserId(getUserId(true));
        return R.ok().put("data", disabilityAuth);
    }

    /**
     * 申请认证
     */
    @PostMapping("/apply")
    //@RequiresPermissions("disabilityauth:disabilityauth:save")
    public R apply(@RequestBody DisabilityAuthEntityDTO dto){
        dto.setUserId(getUserId(true));
		disabilityAuthService.apply(dto);
        return R.ok();
    }



    /**
     * 修改申请
     */
    @PutMapping("/updateApply")
    //@RequiresPermissions("disabilityauth:disabilityauth:update")
    public R update(@RequestBody DisabilityAuthEntityDTO dto){
        dto.setUserId(getUserId(true));
		disabilityAuthService.updateApply(dto);
        return R.ok();
    }

}
